package com.gulimall.order.web;

import com.alipay.api.AlipayApiException;
import com.gulimall.order.config.AlipayTemplate;
import com.gulimall.order.service.OrderService;
import com.gulimall.order.vo.PayVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @ClassName PayWebController
 * @Author 徐涛
 * @Date 2020/11/26 12:04
 */

@Controller
public class PayWebController {
    @Autowired
    AlipayTemplate alipayTemplate;
    @Autowired
    OrderService orderService;
    @ResponseBody
    @GetMapping(value = "/payOrder",produces = "text/html")
    public String payOrder(@RequestParam("OrderSn") String OrderSn) throws AlipayApiException {
/*        PayVo payVo = new PayVo();
        payVo.setOut_trade_no(OrderSn);
        payVo.getBody();
        payVo.setSubject();
        payVo.setTotal_amount();*/
        PayVo payVo= orderService.getOrderPay(OrderSn);
        String pay = alipayTemplate.pay(payVo);
        System.out.println(pay);
        return pay;
    }
}
